import tornado.web
import subprocess
import json


class ApiWebSocketReConn(tornado.web.RequestHandler):

    def get(self, *args, **kwargs):
        # cmd = "ps -ef | grep tornado_client.py | grep -v grep | awk '{print $2, $3}' | xargs kill -9"
        cmd = "ps -ef | grep tornado_client.py | grep -v grep | awk '{print $2, $3}' | xargs kill -TERM"
        subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        resp = {'code': 0}
        self.write(json.dumps(resp, ensure_ascii=False))

    def post(self, *args, **kwargs):
        pass